# -*- coding: utf-8 -*-
# @Author	: brotherbaby
# @Date		: 2023/10/25 10:11
# @Last Modified by:   brotherbaby
# @Last Modified time: 2023/10/25 10:11
# Thanks for your comments!

from sqlalchemy import Column, Integer, VARCHAR, ForeignKey

from src.consts import ModelName
from src.db_proxy.models.modelbase import ModelBase, ModifyingBehevior
from src.db_proxy.models.order import Order


class ShoesDetail(ModelBase, ModifyingBehevior):
    __tablename__ = ModelName.ShoesDetail.value

    id = Column('id', Integer, primary_key=True, autoincrement=True)
    order_id = Column('order_id', Integer, ForeignKey(Order.__tablename__ + '.' + Order.id.name), index=True)  # 提交记录id
    shoes_ecode = Column('shoes_ecode', VARCHAR(64), index=True)  # 鞋子编码
    pic_url = Column('pic_url', VARCHAR(2048))  # 图片地址，多个使用逗号分隔
    status = Column('status', Integer, default=0)  # 状态: 0已提交（待工厂收件），7工厂已收件待入厂，1已入厂，2已出厂，3已退回，4配送中，5已完成
    remark = Column('remark', VARCHAR(256))

    def get_fields(self):
        return {
            "id": self.id,
            "order_id": self.order_id,
            "shoes_ecode": self.shoes_ecode,
            "pic_url": self.pic_url.split(",") if self.pic_url else "",
            "status": self.status,
            "remark": self.remark
        }
